<!-- 相册集上传-->
<button type="button" class="btn btn-success" onClick="upImage()">上传图片</button> <input type="hidden" id="li-pointer" value="">
<div id="thumb_str" style="display: none;">{$info.thumb}</div>
<div class="up-box clearfix">
    <ul id="up-append">
    </ul>
</div>
<div id="up_edit" style="display: none;" title="隐藏的编辑器"></div>
<!-- 相册集上传 -->

<script>
    $(document).ready(function(){

        /*初始化相册内容*/
        // 获取相册内容并且转数组格式
        $thumb_str = $('#thumb_str').text();
        var arg = eval('(' + $thumb_str + ')');
        DivShow(arg);

        // 初始化指针位置
        $l = $("#up-append li").length;
        $("#li-pointer").val($l);


    });
    /*封面上传*/
    var up = UE.getEditor('up_edit');
    //弹出图片上传的对话框
    function upImage()
    {
        var myImage = up.getDialog("insertimage");
        myImage.open();
    }
    //监听图片上传
    up.addListener('beforeInsertImage', function (t,arg)
    {
        DivShow(arg);
    });

    // 显示div
    function DivShow(arr){
        var $str='';
        // 数组长度
        var $arr_length = arr.length;
        // 获取li指针位置
        $length = Number($("#li-pointer").val());


        for(i=0;i<$arr_length;i++){
            $ii = $length+i;
            //alert($ii);
            $str += "<li class='list_"+$ii+"'>";
            $str+= "<input name='up-thumb[]' id='up-thumb-"+i+"' type='hidden' value='"+arr[i].src+"'>";
            $str +="<div class='img'><img src='"+arr[i].src+"' /></div>";

            $str +="<input name='up-title[]' id='up-title-"+i+"' value='"+arr[i].title+"' class='input' placeholder='请设置标题'>"

            if(arr[i]['top'] ==1){
                $str +="<label class='pull-left'><input name='up-top' type='radio' value='"+$ii+"' checked>设置封面 </label>"
            }else{
                $str +="<label class='pull-left'><input name='up-top' type='radio' value='"+$ii+"'/>设置封面 </label>"
            }
            $str +="<label class='pull-right' class='delete'><i class='iconfont icon-shanchu delete' onclick='dele_list("+$ii+")'></i></label>";
            $str += "</li>";
        }

        $(".up-box").css('display','block');
        $("#up-append").append($str)

        // 重新生成指针位置
        $t =  parseInt($length)  + $arr_length;
        $("#li-pointer").val($t);

    }
    // 删除
    function dele_list($id){
        $(".list_"+$id).remove();
    }
</script>